/**
 * Created by Void on 2017/7/19.
 */

import {Component, Input, Output, EventEmitter} from '@angular/core';

/**
 * @name 定义首页的cell 在其他页面重复使用
 * @description
 * @example <home-cell [src]='www.baidu.com' [likeCount]='300' [title]="阿飞" (cellClick)="cellSelected($event)" (likeClick)="like($event)"></page-pagination>
 * @example <page-pagination [total]="total" (search)="doSearch($event)" pageSize="10" color="dark"></page-pagination>
 */

@Component({
    selector: 'home-cell',
    templateUrl: 'homecell.html'
})

export class HomeCell{
    @Input()
    cellModel:Object; // 存放数据的model
    @Input()
    cellIndex:number; // 该cell所在的位置

    @Output()
    cellClick = new EventEmitter<number>();//点击cell触发的事件
    @Output()
    likeClick = new EventEmitter<number>();//点击like触发的事件

    constructor() {
    }

    cellSelect(){
        this.cellClick.emit(this.cellIndex);
    }

    likeSelect(){
        event.stopPropagation();
        this.likeClick.emit(this.cellIndex);
    }

}